﻿package com.tudou.home.controller
{
    import com.tudou.cookie.*;
    import com.tudou.home.commands.*;
    import com.tudou.home.commands.ad.*;
    import com.tudou.home.model.*;
    import com.tudou.home.newskin.model.*;
    import com.tudou.home.utils.*;
    import com.tudou.home.view.*;
    import com.tudou.track.*;
    import org.puremvc.as3.interfaces.*;
    import org.puremvc.as3.patterns.command.*;

    public class PlayListSingleCommand extends SimpleCommand implements ICommand
    {

        public function PlayListSingleCommand()
        {
            return;
        }// end function

        override public function execute(param1:INotification) : void
        {
            var _loc_2:PlayListSingleProxy = null;
            var _loc_8:Array = null;
            var _loc_9:int = 0;
            var _loc_10:PlayerSO = null;
            var _loc_11:Boolean = false;
            _loc_2 = facade.retrieveProxy(PlayListSingleProxy.NAME) as PlayListSingleProxy;
            var _loc_3:* = facade.retrieveProxy(PlayerProxy.NAME) as PlayerProxy;
            var _loc_4:* = facade.retrieveMediator(SkinMediator.NAME) as SkinMediator;
            var _loc_5:* = facade.retrieveProxy(PageProxy.NAME) as PageProxy;
            var _loc_6:* = PageInfo.getInstance();
            var _loc_7:* = param1.getBody();
            switch(param1.getName())
            {
                case PlayListSingleCommandSet.PLAY_LIST_LOADED:
                {
                    _loc_2.setRelativeList(_loc_7);
                    _loc_4.showTransFinished = _loc_2.showTransFinished;
                    _loc_8 = _loc_2.getPlayList();
                    _loc_4.setRelativeList(_loc_2.getPlayList());
                    break;
                }
                case PlayListSingleCommandSet.CHANGE_ITEM:
                {
                    _loc_4.stopTransFinishTimeout();
                    _loc_9 = 0;
                    sendNotification(AdCommandSet.CLEAR_ALL);
                    PlayTimeTracker.getInst().stop();
                    if (SingleItemOpenUrl.TRANS_FINISH_AUTO == SingleItemOpenUrl.openType)
                    {
                        _loc_5.startPlayVideo(_loc_9, true, {FR:SingleItemOpenUrl.openType});
                    }
                    else
                    {
                        SingleItemOpenUrl.gotoUrl((_loc_7 as IBaseVideoInfo).href, {});
                    }
                    break;
                }
                case PlayListSingleCommandSet.NEXT_ITEM:
                {
                    _loc_2.nextItem();
                    break;
                }
                case PlayListSingleCommandSet.PREV_ITEM:
                {
                    _loc_2.prevItem();
                    break;
                }
                case PlayListSingleCommandSet.THIS_INDEX:
                {
                    _loc_6.changeItemManual = true;
                    _loc_2.thisIndex(param1.getBody() as uint);
                    break;
                }
                case PlayListSingleCommandSet.SET_COOKIE_PLAYLIST_SINGLE_CONTINUE:
                {
                    _loc_10 = PlayerSO.getInst();
                    _loc_11 = _loc_7 as Boolean;
                    _loc_10.playListSingleContinue = _loc_11;
                    _loc_4.setPlaylistSingleContinue(_loc_11);
                    break;
                }
                default:
                {
                    break;
                    break;
                }
            }
            return;
        }// end function

    }
}
